package com.maple.soa.util;

import org.apache.commons.codec.binary.Hex;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author lijian
 * @date 2020/5/27
 */
public class ShaUtils {

    public static String encryptSha(String data, String algorithm) {
        MessageDigest messageDigest = null;
        try {
            messageDigest = MessageDigest.getInstance(algorithm);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        messageDigest.update(data.getBytes());
        return Hex.encodeHexString(messageDigest.digest());
    }

}
